
<template>
  <avue-crud
    ref="crud"
    :page="page"
    :data="tableData"
    :table-loading="tableLoading"
    :option="tableOption"
    @on-load="getList"
  >
    <template
      slot="errMsg"
      slot-scope="scope"
    >
      <span style="color: red">{{scope.row.errMsg}}</span>
    </template>
    <template slot="bankName">
      <span>{{bankType === 'boc' ? '中国银行' : '建设银行'}}</span>
    </template>
  </avue-crud>
</template>

<script>
import { fileData } from "@/api/rca/swckbankcashpaymentnote";
import { tableOption } from "@/const/crud/rca/swckbankcashpaymentnote";
import { deepClone } from '@/util/util'
import { mapGetters } from "vuex";

export default {
  name: "TempData",
  data () {
    return {
      searchForm: {},
      tableData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20, // 每页显示多少条
      },

      tableLoading: false,
    };
  },
  props: ["bankType"],
  computed: {
    tableOption () {
      const opt = deepClone(tableOption)
      opt.column = opt.column.map(item => {
        return { ...item, search: false }
      })
      opt.column.push({
        type: 'input',
        label: '数据提醒',
        prop: 'errMsg',
        slot: true
      })
      opt.menu = false;
      opt.selection = false;
      return opt;
    },
  },
  methods: {
    getList (page, params) {
      this.tableLoading = true;
      fileData
        .list({
          current: page.currentPage,
          size: page.pageSize,
        })
        .then((response) => {
          this.tableData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
  },
};
</script>
